home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tex / shapiro-btxbst-0.98.doc < prev    next >
Encoding:
Text File  |  1988-04-18  |  55.9 KB  |  2,301 lines

  1. # if 0
  2. % BibTeX `plain' family
  3. % modified to ouput fields in French; shapiro@corto.inria.fr 30-oct-87
  4. % Further modified for 'alpha3' and 'long' styles 3-nov-87
  5. % and for 'key' and 'skey' 1-jan-88
  6. # endif 0
  7.     % version 0.98c for BibTeX versions 0.98i or later, LaTeX version 2.08
  8.     % Copyright (C) 1985, all rights reserved
  9.     % Copying of this file is authorized only if either
  10.     % (1) you make absolutely no changes to your copy, including name, or
  11.     % (2) if you do make changes, you name it something other than
  12.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst
  13.     % This restriction helps ensure that all standard styles are identical
  14. # if 0
  15. % This is file btxbxt.doc; it helps document bibliography styles,
  16. % and is also a template file that you can use to make
  17. % several different style files, if you have access to a C preprocessor.
  18. % For example, the standard styles were made by something like
  19. %    cpp -P -DPLAIN btxbst.doc | sed -e '/^$/d' > plain.bst
  20. %    cpp -P -DUNSRT btxbst.doc | sed -e '/^$/d' > unsrt.bst
  21. %    cpp -P -DALPHA btxbst.doc | sed -e '/^$/d' > alpha.bst
  22. %    cpp -P -DABBRV btxbst.doc | sed -e '/^$/d' > abbrv.bst
  23. % A French version of (say) abbrv is created by
  24. %    cpp -P -DABBRV -DFRENCH btxbst.doc | sed -e '/^$/d' > fabbrv.bst
  25. % There are also new styles created by defining ALPHA3, KEY, SKEY or LONG.
  26. %       ALPHA3 label is first 3 letters of 1st author's name + year
  27. %       LONG   label is 1st author's full name + year
  28. %       KEY    label is the bibtex key, the bibliogrpahy is unsorted
  29. %       SKEY   label is the bibtex key, sorted by 1st author's name&year
  30. % The last two styles are intended for printing the database itself.
  31. %
  32. % If you don't have access,
  33. % you can edit this file by hand to imitate the preprocessor,
  34. % with the following explanation of the C preprocessor constructs used here.
  35. %
  36. % The output of the preprocessor is the same as the input, except that certain
  37. % lines will be excluded (and some blank lines will be added).  The sequence
  38. %    #if VAR
  39. %        lines to be included when VAR is not zero
  40. %    #else
  41. %        lines to be included when VAR is zero
  42. %    #endif
  43. % (with the #-signs appearing in column 1) means that one set or the other of
  44. % the lines are to be included depending on the value of VAR.
  45. % The #else part is optional.  Comments can be added after #else and #endif.
  46. % The '# if 0' ... '#endif' sequence is used to eliminate unnecessary
  47. % comments from the output.
  48. % Variables can be set by
  49. %    #define VAR value
  50. % and one can also use #ifdef VAR to see if VAR has any value, and #ifndef
  51. % to see if it has none.
  52. % Another #if form used in this file is #if !VAR, which includes the lines
  53. % after the #if only if VAR is zero.
  54. %
  55. % Convention: Use all uppercase identifiers for these preprocessor variables
  56. % so you can spot them easily
  57. %
  58. % The command line to the preprocessor should define one of PLAIN, UNSRT, ALPHA
  59. % or ABBRV (though PLAIN will be used by default if none is given),
  60. % and the following lines will set various boolean variables to control the
  61. % various lines that are chosen from the rest of the file.
  62. % Each boolean variable should be set true (1) or false (0) in each style.
  63. % Here are the current variables, and their meanings:
  64. %    LAB_ALPH:    an alphabetic label is used (if false then a numeric
  65. %                label is used)
  66. %    SORTED:        the entries should be sorted by label (if nonnumeric)
  67. %                and other info, like authors (if false, then
  68. %                entries remain in order of occurrence)
  69. %    NAME_FULL:    the authors, editors, etc., get the full names as
  70. %                given in the bibliograph (if false, the first
  71. %                names become initials)
  72. %    ATIT_LOWER:    titles of non-"books" (e.g., articles) should be
  73. %                converted to lower-case, except the first letter
  74. %                (if false then they appear as in the database)
  75. %    MONTH_FULL:    months are spelled out in full (if false, then
  76. %                they're abbreviated)
  77. %    JOUR_FULL:    macro journal names are spelled out in full
  78. %                (if false then they are abbreviated, currently
  79. %                as they appear in ACM publications)
  80. %       LBKEYS:         use the database key as the citation label
  81. % Furthermore the variable ALPHA_LONG may have one of the following
  82. % values, when LAB_ALPH is 1, giving the following citation alphabetic
  83. % label format:
  84. % 0 [Lam85] for single author (or editor or key): first 3 letters of last name
  85. %   [SW79]  (first letters of last names) for multiple authors
  86. % 1 [Lam85] for single author (or editor or key)
  87. %   [Str79]  (first 3 letters of 1st author's last name) for multiple authors
  88. % 2 [Lamport 85] for single author (or editor or key): full last name
  89. %   [Strunk 79]  (full last name of 1st author) for multiple authors
  90. # endif 0
  91.  
  92. #ifndef UNSRT
  93. #   ifndef ALPHA
  94. #    ifndef ABBRV
  95. #           ifndef ALPHA3
  96. #               ifndef LONG
  97. #                   ifndef KEY
  98. #                       ifndef SKEY
  99. #                              define PLAIN 1
  100. #                       endif
  101. #                   endif
  102. #               endif
  103. #           endif
  104. #    endif
  105. #   endif
  106. #endif
  107. #ifdef PLAIN
  108. % plain style (sorted numbers)
  109. #   define LAB_ALPH 0
  110. #   define SORTED 1
  111. #   define NAME_FULL 1
  112. #   define ATIT_LOWER 1
  113. #   define MONTH_FULL 1
  114. #   define JOUR_FULL 1
  115. #   define LBKEYS 0
  116. #endif
  117. #ifdef UNSRT
  118. % unsrt style (unsorted numbers)
  119. #   define LAB_ALPH 0
  120. #   define SORTED 0
  121. #   define NAME_FULL 1
  122. #   define ATIT_LOWER 1
  123. #   define MONTH_FULL 1
  124. #   define JOUR_FULL 1
  125. #   define LBKEYS 0
  126. #endif
  127. #ifdef ALPHA
  128. % alpha style (sorted short alphabetics)
  129. #   define LAB_ALPH 1
  130. #   define ALPHA_LONG 0
  131. #   define SORTED 1
  132. #   define NAME_FULL 1
  133. #   define ATIT_LOWER 1
  134. #   define MONTH_FULL 1
  135. #   define JOUR_FULL 1
  136. #   define LBKEYS 0
  137. #endif
  138. #ifdef ALPHA3
  139. % alpha3 style (sorted short alphabetics, 3 letters of 1st author only)
  140. #   define LAB_ALPH 1
  141. #   define ALPHA_LONG 1
  142. #   define SORTED 1
  143. #   define NAME_FULL 1
  144. #   define ATIT_LOWER 1
  145. #   define MONTH_FULL 1
  146. #   define JOUR_FULL 1
  147. #   define LBKEYS 0
  148. #endif
  149. #ifdef LONG
  150. % long style (sorted long alphabetics, full name of 1st author only)
  151. #   define LAB_ALPH 1
  152. #   define ALPHA_LONG 2
  153. #   define SORTED 1
  154. #   define NAME_FULL 1
  155. #   define ATIT_LOWER 1
  156. #   define MONTH_FULL 1
  157. #   define JOUR_FULL 1
  158. #   define LBKEYS 0
  159. #endif
  160. #ifdef ABBRV
  161. % abbrv style (sorted numbers, with abbreviations)
  162. #   define LAB_ALPH 0
  163. #   define SORTED 1
  164. #   define JOUR_FULL 0
  165. #   define MONTH_FULL 0
  166. #   define ATIT_LOWER 1
  167. #   define NAME_FULL 0
  168. #   define LBKEYS 0
  169. #endif
  170. #ifdef KEY
  171. % keys style (unsorted keys)
  172. #   define LAB_ALPH 1
  173. #   define ALPHA_LONG 2
  174. #   define SORTED 0
  175. #   define NAME_FULL 0
  176. #   define ATIT_LOWER 1
  177. #   define MONTH_FULL 0
  178. #   define JOUR_FULL 1
  179. #   define LBKEYS 1
  180. #endif
  181. #ifdef SKEY
  182. % skeys style (keys, sorted by name of 1st author and year)
  183. #   define LAB_ALPH 1
  184. #   define ALPHA_LONG 2
  185. #   define SORTED 1
  186. #   define NAME_FULL 1
  187. #   define ATIT_LOWER 1
  188. #   define MONTH_FULL 0
  189. #   define JOUR_FULL 1
  190. #   define LBKEYS 1
  191. #endif
  192. #ifdef FRENCH
  193. % French version
  194. #endif FRENCH
  195. %
  196. # if 0
  197. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  198. %    in "A Handbook for Scholars".  Book-like titles are italicized and
  199. %    non-book titles are converted to sentence capitilization
  200. %    (and not enclosed in quotes).
  201. %    This file outputs a \newblock between major blocks of an entry
  202. %    (the name \newblock is analogous to the names \newline and \newpage)
  203. %    so that the user can obtain an "open" format, which has a line break
  204. %    before each block and lines after the first are indented within blocks,
  205. %    by giving an optional \documentstyle argument; currently there is a
  206. %    required `optional' \documentstyle argument, one of
  207. %        opbiba, opbibr, clbiba, or clbibr,
  208. %    giving an open or closed format for an article or report.
  209. %    For the next version of LaTeX there will be just one, truly optional
  210. %    style, for the open format
  211. %    (among other things, it will have improved page breaking).
  212. %    The default will be the "closed" format---blocks runs together.
  213. %
  214. %   Citation alphabetic label format:
  215. %        [Knu73] for single author (or editor or key)
  216. %        [AHU83] (first letters of last names) for multiple authors
  217. %
  218. %   Citation label numberic format:
  219. %        [number]
  220. %
  221. %   Reference list ordering for sorted, alphabetic lables:
  222. %        alphabetical by citation label, then by author(s) or whatever
  223. %        passes for author in the absence of one, and then by title.
  224. %
  225. %   Reference list ordering for sorted, numeric lables:
  226. %        alphabetical by author(s) or whatever passes
  227. %        passes for author in the absence of one, and then by title.
  228. %
  229. %   Reference list ordering for unsorted:
  230. %        by the order cited in the text
  231. %
  232. %   History
  233. %   12/16/84    (HWT)    Original `plain' version, by Howard Trickey.
  234. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  235. %    2/16/85    (OP)    Changes based on LL's comments, Oren Patashnik
  236. %    2/17/85    (HWT)    template file and other standard styles made
  237. %    3/28/85        First release, version 0.98b for BibTeX 0.98f
  238. %    5/ 9/85        version 0.98c for BibTeX 0.98i
  239. %             : fixed Theoretical Computer Science macro name
  240. %             : fixed the format.vol.num.pages function
  241. %
  242. % The ENTRY declaration
  243. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  244. %   but no fullauthor or editors fields because BibTeX does name handling.
  245. %   The annote field is commented out here because this family doesn't
  246. %   include an annotated bibliography style
  247. # endif 0
  248.  
  249. ENTRY
  250. % Fields:
  251.   { address
  252. %        Publisher's address
  253. %    annote
  254. %        Long annotation used for annotated bibliographies (begins sentence)
  255.     author
  256. %        Name(s) of author(s), in BibTeX name format
  257.     booktitle
  258. %        Book title when the thing being referenced isn't the whole book.
  259. %        For book entries, the title field should be used instead.
  260.     chapter
  261. %        Chapter number
  262.     edition
  263. %        Edition of a book (e.g., "second")
  264.     editor
  265. %        Name(s) of editor(s), in BibTeX name format.
  266. %        If there is also an author field, then the editor field should be
  267. %        for the book or collection that the work appears in
  268.     howpublished
  269. %         How something strange has been published (begins sentence)
  270.     institution
  271. %        Sponsoring institution
  272.     journal
  273. %        Journal name (macros are provided for many)
  274.     key
  275. %        Alphabetizing and labeling key (needed when no author or editor)
  276.     month
  277. %        Month (macros are provided)
  278.     note
  279. %        To help the reader find a reference (begins sentence)
  280.     number
  281. %        Number of a journal or technical report
  282.     organization
  283. %        Organization (sponsoring a conference)
  284.     pages
  285. %        Page number or numbers (use `--' to separate a range)
  286.     publisher
  287. %        Publisher name
  288.     school
  289. %        School name (for theses)
  290.     series
  291. %        The name of a series or set of books.
  292. %        An individual book will will also have it's own title
  293.     title
  294. %        The title of the thing being referenced
  295.     type
  296. %        Type of a Techreport (e.g., "Research Note") to be used instead of
  297. %        the default "Technical Report"
  298.     volume
  299. %        Volume of a journal or multivolume work
  300.     year
  301. %        Year---should contain only numerals
  302.   }
  303. # if 0
  304. % There are no integer entry variables
  305. # endif 0
  306.   {}
  307. # if 0
  308. % These string entry variables are used to form the citation label.
  309. % In a storage pinch, sort.label can be easily computed on the fly.
  310. # endif 0
  311.  
  312. #if LAB_ALPH
  313. #if SORTED
  314.   { label extra.label sort.label }
  315. #else !SORTED
  316. # if 0
  317. % It still doesn't seem like a good idea to use an order-of-citation
  318. % reference list when using alphabetic labels, but when this happens we
  319. % do things a little differently
  320. # endif 0
  321.   {label}
  322. #endif SORTED
  323. #else !LAB_ALPH
  324.   {label}
  325. #endif LAB_ALPH
  326.  
  327. # if 0
  328. % Each entry function starts by calling output.bibitem, to write the
  329. % \bibitem and its arguments to the .BBL file.  Then the various fields
  330. % are formatted and printed by output or output.check.  Those functions
  331. % handle the writing of separators (commas, periods, \newblock's),
  332. % taking care not to do so when they are passed a null string.
  333. % Finally, fin.entry is called to add the final period and finish the
  334. % entry.
  335. %
  336. % A bibliographic reference is formatted into a number of `blocks':
  337. % in the open format, a block begins on a new line and subsequent
  338. % lines of the block are indented.  A block may contain more than
  339. % one sentence (well, not a grammatical sentence, but something to
  340. % be ended with a sentence ending period).  The entry functions should
  341. % call new.block whenever a block other than the first is about to be
  342. % started.  They should call new.sentence whenever a new sentence is
  343. % to be started.  The output functions will ensure that if two
  344. % new.sentence's occur without any non-null string being output between
  345. % them then there won't be two periods output.  Similarly for two
  346. % successive new.block's.
  347. %
  348. % The output routines don't write their argument immediately.
  349. % Instead, by convention, that argument is saved on the stack to be
  350. % output next time (when we'll know what separator needs to come
  351. % after it).  Meanwhile, the output routine has to pop the pending
  352. % output off the stack, append any needed separator, and write it.
  353. %
  354. % To tell which separator is needed, we maintain an output.state.
  355. % It will be one of these values:
  356. %    before.all        just after the \bibitem
  357. %    mid.sentence        in the middle of a sentence: comma needed
  358. %                    if more sentence is output
  359. %    after.sentence        just after a sentence: period needed
  360. %    after.block        just after a block (and sentence):
  361. %                    period and \newblock needed.
  362. % Note: These styles don't use after.sentence
  363. %
  364. % VAR: output.state : INTEGER        -- state variable for output
  365. %
  366. % The output.nonnull function saves its argument (assumed to be nonnull)
  367. % on the stack, and writes the old saved value followed by any needed
  368. % separator.  The ordering of the tests is decreasing frequency of
  369. % occurrence.
  370. %
  371. % output.nonnull(s) ==
  372. %  BEGIN
  373. %    s := argument on stack
  374. %    if output.state = mid.sentence then
  375. %        write$(pop() * ", ")
  376. %          -- "pop" isn't a function: just use stack top
  377. %    else
  378. %        if output.state = after.block then
  379. %        write$(add.period$(pop()))
  380. %        newline$
  381. %        write$("\newblock ")
  382. %        else
  383. %        if output.state = before.all then
  384. %            write$(pop())
  385. %        else        -- output.state should be after.sentence
  386. %            write$(add.period$(pop()) * " ")
  387. %        fi
  388. %        fi
  389. %    fi
  390. %    push s on stack
  391. %    output.state := mid.sentence
  392. %  END
  393. %
  394. % The output function calls output.nonnull if its argument is non-null
  395. %
  396. % output(s) ==
  397. %  BEGIN
  398. %    if s <> "" then output.nonnull(s)
  399. %    fi
  400. %  END
  401. %
  402. % The output.check function calls output.nonnull if s is non-null
  403. % and warns the user that the t field shouldn't be empty (this is
  404. % because it won't be a good reference without the field;  the entry
  405. % functions try to make the formatting look reasonable even when such
  406. % fields are empty).
  407. %
  408. % output.check(t,s) ==
  409. %  BEGIN
  410. %    if s = "" then
  411. %        top$("Warning: the " * t * " shouldn't be empty in " * cite$)
  412. %    else output.nonnull(s)
  413. %    fi
  414. %  END
  415. %
  416. % The output.bibitem function writes the \bibitem for the current entry
  417. % (the label should already have been set up), and sets up the separator
  418. % state for the output functions.  And, it leaves a string on the stack
  419. % as per the output convention.
  420. %
  421. % output.bibitem ==
  422. %  BEGIN
  423. %    newline$
  424. %    write$("\bibitem[")    % for alphabetic labels,
  425. %    write$(label)        % these three lines
  426. %    write$("]{")        % are used
  427. %    write$("\bibitem{")        % this line for numeric labels
  428. %    write$(cite$)
  429. %    write$("}")
  430. %    push "" on stack
  431. %    output.state := before.all
  432. %  END
  433. %
  434. % The fin.entry function finishes off an entry by adding a period to the
  435. % string remaining on the stack.  If the state is still before.all
  436. % then nothing was produced for this entry, so the result will look bad,
  437. % but the user deserves it. (We don't omit the whole entry because the
  438. % entry was cited, and a bibitem is needed to define the citation label.)
  439. %
  440. % fin.entry ==
  441. %  BEGIN
  442. %    write$(add.period$(pop()))
  443. %    newline$
  444. %  END
  445. %
  446. % The new.block function prepares for a new block to be output, and
  447. % new.sentence prepares for a new sentence.
  448. %
  449. % new.block ==
  450. %  BEGIN
  451. %    if output.state <> before.all then
  452. %        output.state := after.block
  453. %    fi
  454. %  END
  455. %
  456. % new.sentence ==
  457. %  BEGIN
  458. %    if output.state <> after.block then
  459. %        if output.state <> before.all then
  460. %        output.state :=  after.sentence
  461. %        fi
  462. %    fi
  463. %  END
  464. %
  465. # endif 0
  466.  
  467. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  468.  
  469. FUNCTION {init.state.consts}
  470. { 'before.all #0 :=
  471.   'mid.sentence #1 :=
  472.   'after.sentence #2 :=
  473.   'after.block #3 :=
  474. }
  475.  
  476. # if 0
  477. % the variables s and t are temporary string holders
  478. # endif 0
  479.  
  480. STRINGS { s t }
  481.  
  482. FUNCTION {output.nonnull}
  483. { 's swap$ :=
  484.   output.state mid.sentence =
  485.     { ", " * write$ }
  486.     { output.state after.block =
  487.     { add.period$ write$
  488.       newline$
  489.       "\newblock " write$
  490.     }
  491.     { output.state before.all =
  492.         'write$
  493.         { add.period$ " " * write$ }
  494.       if$
  495.     }
  496.       if$
  497.     }
  498.   if$
  499.   'output.state mid.sentence :=
  500.   s
  501. }
  502.  
  503. FUNCTION {output}
  504. { 's swap$ :=
  505.   s "" =
  506.     'skip$
  507.     { s output.nonnull }
  508.   if$
  509. }
  510.  
  511. FUNCTION {output.check}
  512. { 's swap$ :=
  513.   't swap$ :=
  514.   s "" =
  515.     { "Warning: the " t * " shouldn't be empty in " * cite$ * top$ }
  516.     { s output.nonnull }
  517.   if$
  518. }
  519.  
  520. FUNCTION {output.bibitem}
  521. { newline$
  522. #if LAB_ALPH
  523.   "\bibitem[" write$
  524.   label write$
  525.   "]{" write$
  526. #else
  527.   "\bibitem{" write$
  528. #endif
  529.   cite$ write$
  530.   "}" write$
  531.   newline$
  532.   ""
  533.   'output.state before.all :=
  534. }
  535.  
  536. # if 0
  537. % This function finishes all entries.  Note: For an otherwise empty entry
  538. % (which is probably due to a user error) this function prints a
  539. period
  540. # endif 0
  541.  
  542. FUNCTION {fin.entry}
  543. { add.period$
  544.   write$
  545.   newline$
  546. }
  547.  
  548. FUNCTION {new.block}
  549. { output.state before.all =
  550.     'skip$
  551.     { 'output.state after.block := }
  552.   if$
  553. }
  554.  
  555. # if 0
  556. % This function isn't used in these styles
  557. # endif 0
  558.  
  559. FUNCTION {new.sentence}
  560. { output.state after.block =
  561.     'skip$
  562.     { output.state before.all =
  563.     'skip$
  564.     { 'output.state after.sentence := }
  565.       if$
  566.     }
  567.   if$
  568. }
  569.  
  570. # if 0
  571. % These three functions pop one or two (integer) arguments from the stack
  572. % and push a single one, either 0 or 1.
  573. % The 'skip$ in the `and' and `or' functions are used because
  574. % the corresponding if$ would be idempotent
  575. # endif 0
  576.  
  577. FUNCTION {not}
  578. {   { #0 }
  579.     { #1 }
  580.   if$
  581. }
  582.  
  583. FUNCTION {and}
  584. {   'skip$
  585.     { pop$ #0 }
  586.   if$
  587. }
  588.  
  589. FUNCTION {or}
  590. {   { pop$ #1 }
  591.     'skip$
  592.   if$
  593. }
  594.  
  595. # if 0
  596. % Here are some functions for formatting chunks of an entry.
  597. % By convention they either produce a string that can be followed by
  598. % a comma or period (using add.period$, so it is OK to end in a period),
  599. % or they produce the null string.
  600. %
  601. % A useful utility is the field.or.null function, which checks if the
  602. % argument is the result of pushing a `missing' field (one for which no
  603. % assignment was made when the current entry was read in from the database),
  604. % and returns the null string if so, otherwise it returns the field string.
  605. %
  606. % field.or.null(s) ==
  607. %  BEGIN
  608. %    if missing$(s) then return ""
  609. %    else return s
  610. %  END
  611. %
  612. % Another helper function is italicize, which returns the string that
  613. % italicizes the argument string, if that is non-null, otherwise it
  614. % returns the null string.  Italic corrections aren't used, so this
  615. % function should be used when punctation will follow the result.
  616. % Also, it needn't be \em (instead of \it) because the user shouldn't be
  617. % emphasizing the whole bibliography.
  618. %
  619. % italicize(s) ==
  620. %  BEGIN
  621. %    if s = "" then return ""
  622. %    else return "{\it " * s * "}"
  623. %
  624. % The format.names function formats the argument (which should be in
  625. % BibTeX name format) into "First Von~Last, Junior", separated by commas
  626. % and with an "and" before the last (but ending with "et al." if the last
  627. % of multiple authors is "others")
  628. %
  629. % VAR: nameptr, namesleft, numnames: INTEGER
  630. %      nameresult: STRING
  631. %
  632. % format.names(s) ==
  633. %  BEGIN
  634. %    nameptr := 1
  635. %    nameresult := ""
  636. %    numnames := num.names$(s)
  637. %    namesleft := numnames
  638. %    while namesleft > 0
  639. %      do
  640. %                % for full names:
  641. %        t := format.name$(s, nameptr, "{ff }{vv~}{ll}{, jj}")
  642. %                % for abbreviated first names:
  643. %        t := format.name$(s, nameptr, "{f.~}{vv~}{ll}{, jj}")
  644. %        if nameptr > 1 then
  645. %        if namesleft > 1 then nameresult := nameresult * ", " * t
  646. %        else if numnames > 2
  647. %               then nameresult := nameresult * ","
  648. %             fi
  649. %             if t = "others"
  650. %               then nameresult := nameresult * " et al."
  651. %               else nameresult := nameresult * " and " * t
  652. %             fi
  653. %        fi
  654. %        else nameresult := nameresult * t
  655. %        fi
  656. %        nameptr := nameptr + 1
  657. %        namesleft := namesleft - 1
  658. %      od
  659. %    return nameresult
  660. %  END
  661. %
  662. % The format.authors function returns the result of format.names(author)
  663. % if the author is present, or else it returns the null string
  664. %
  665. % format.authors ==
  666. %  BEGIN
  667. %    if missing$(author) then return ""
  668. %    else return format.names(author)
  669. %    fi
  670. %  END
  671. %
  672. % Format.editors is like format.authors, but it uses the editor field,
  673. % and appends ", editor" or ", editors"
  674. %
  675. % format.editors ==
  676. %  BEGIN
  677. %    if missing$(editor) then return ""
  678. %    else
  679. %        if num.names$(editor) > 1 then
  680. %        return format.names(editor) * ", editors"
  681. %        else
  682. %        return format.names(editor) * ", editor"
  683. %        fi
  684. %    fi
  685. %  END
  686. %
  687. % Other formatting functions are similar, so no "comment version" will be
  688. % given for them.
  689. %
  690. % The `pop$' in this function gets rid of the duplicate `missing' value and
  691. % the `skip$' returns the duplicate field value
  692. # endif 0
  693.  
  694. FUNCTION {field.or.null}
  695. { duplicate$
  696.   missing$
  697.     { pop$ "" }
  698.     'skip$
  699.   if$
  700. }
  701.  
  702. FUNCTION {italicize}
  703. { 's swap$ :=
  704.   s "" =
  705.     { "" }
  706.     { "{\it " s * "}" * }
  707.   if$
  708. }
  709.  
  710. INTEGERS { nameptr namesleft numnames }
  711.  
  712. STRINGS {nameresult}
  713.  
  714. FUNCTION {format.names}
  715. { 's swap$ :=
  716.   'nameptr #1 :=
  717.   'nameresult "" :=
  718.   'numnames s num.names$ :=
  719.   'namesleft numnames :=
  720.     { namesleft #0 > }
  721.     {
  722. #if NAME_FULL
  723.       't s nameptr "{ff }{vv~}{ll}{, jj}" format.name$ :=
  724. #else
  725.       't s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ :=
  726. #endif
  727.       nameptr #1 >
  728.     { namesleft #1 >
  729.         { 'nameresult nameresult ", " * t * := }
  730.         { numnames #2 >
  731.         { 'nameresult nameresult "," * := }
  732.         'skip$
  733.           if$
  734.           t "others" =
  735.         { 'nameresult nameresult " et al." * := }
  736. #ifndef FRENCH
  737.         { 'nameresult nameresult " and " * t * := }
  738. #else FRENCH
  739.         { 'nameresult nameresult " et " * t * := }
  740. #endif FRENCH
  741.           if$
  742.         }
  743.       if$
  744.     }
  745.     { 'nameresult nameresult t * := }
  746.       if$
  747.       'nameptr nameptr #1 + :=
  748.       'namesleft namesleft #1 - :=
  749.     }
  750.   while$
  751.   nameresult
  752. }
  753.  
  754. FUNCTION {format.authors}
  755. { author missing$
  756.     { "" }
  757.     { author format.names }
  758.   if$
  759. }
  760.  
  761. FUNCTION {format.editors}
  762. { editor missing$
  763.     { "" }
  764.     { editor num.names$ #1 >
  765. #ifndef FRENCH
  766.     { editor format.names ", editors" * }
  767.     { editor format.names ", editor" * }
  768. #else FRENCH
  769.     { editor format.names ", \'{e}diteurs" * }
  770.     { editor format.names ", \'{e}diteur" * }
  771. #endif FRENCH
  772.       if$
  773.     }
  774.   if$
  775. }
  776.  
  777. # if 0
  778. % The format.title function is used for non-book-like titles.
  779. % For most styles we convert to lowercase (except for the very first letter),
  780. % and hope the user has brace-surrounded words that need to stay capitilized;
  781. % for some, however, we leave it as it is in the database.
  782. # endif 0
  783.  
  784. FUNCTION {format.title}
  785. #if ATIT_LOWER
  786. { title missing$
  787.     { "" }
  788.     { title "ul" change.case$ }
  789.   if$
  790. #else
  791. { title field.or.null
  792. #endif ATIT_LOWER
  793. }
  794.  
  795. # if 0
  796. % The entry.string.max function is set to BibTeX's ent_str_size constant,
  797. % the maximum length of an entry string variable.
  798. %
  799. % The global.string.max function is set to BibTeX's glob_str_size constant,
  800. % the maximum length of a global string variable.
  801. # endif 0
  802.  
  803. FUNCTION {entry.string.max} { #100 }
  804.  
  805. FUNCTION {global.string.max} { #300 }
  806.  
  807. # if 0
  808. % The n.dashify function makes each single `-' in a string a double `--'
  809. % if it's not already
  810. %
  811. % VAR: pageresult: STRING
  812. %
  813. % n.dashify(s) ==
  814. %  BEGIN
  815. %    t := s
  816. %    pageresult := ""
  817. %    while (not (t = ""))
  818. %      do
  819. %        if (first character of t = "-")
  820. %          then
  821. %        if (next character isn't)
  822. %          then
  823. %            pageresult := pageresult * "--"
  824. %            t := t with the "-" removed
  825. %          else
  826. %            while (first character of t = "-")
  827. %              do
  828. %            pageresult := pageresult * "-"
  829. %            t := t with the "-" removed
  830. %              od
  831. %        fi
  832. %          else
  833. %        pageresult := pageresult * the first character
  834. %        t := t with the first character removed
  835. %        fi
  836. %      od
  837. %    return pageresult
  838. %  END
  839. # endif 0
  840.  
  841. STRINGS {pageresult}
  842.  
  843. FUNCTION {n.dashify}
  844. { 't swap$ :=
  845.   'pageresult "" :=
  846.     { t "" = not }
  847.     { t #1 #1 substring$ "-" =
  848.     { t #1 #2 substring$ "--" = not
  849.         { 'pageresult pageresult "--" * :=
  850.           't t #2 global.string.max substring$ :=
  851.         }
  852.         {   { t #1 #1 substring$ "-" = }
  853.         { 'pageresult pageresult "-" * :=
  854.           't t #2 global.string.max substring$ :=
  855.         }
  856.           while$
  857.         }
  858.       if$
  859.     }
  860.     { 'pageresult pageresult t #1 #1 substring$ * :=
  861.       't t #2 global.string.max substring$ :=
  862.     }
  863.       if$
  864.     }
  865.   while$
  866.   pageresult
  867. }
  868.  
  869. # if 0
  870. % The format.date function is for the month and year, but we give a warning if
  871. % there's a missing year but the month is there, and we return the empty string
  872. % if they're both missing
  873. # endif 0
  874.  
  875. FUNCTION {format.date}
  876. { year missing$
  877.     { month missing$
  878.     { "" }
  879.     { "Warning: there's a month but no year in " cite$ * top$
  880.       month
  881.     }
  882.       if$
  883.     }
  884.     { month missing$
  885.     { year }
  886.     { month " " * year * }
  887.       if$
  888.     }
  889.   if$
  890. }
  891.  
  892. # if 0
  893. % The format.btitle is for formatting the title field when it is a book-like
  894. % entry---the style used here keeps it in uppers-and-lowers and italicizes it.
  895. # endif 0
  896.  
  897. FUNCTION {format.btitle}
  898. { title field.or.null
  899.   italicize
  900. }
  901.  
  902. # if 0
  903. % The format.bvolume function is for formatting the volume number and/or
  904. % series name of a multivolume book.  If the volume field is missing, we
  905. % output either the series field italicized if it exists or the null string
  906. % otherwise.  If both the volume and series fields are there, we assume the
  907. % series field is the title of the whole multivolume work (the title field
  908. % should be the title of the one referred to), and add an "of <series>".
  909. % A tie (~) is put between the "Volume" and the volume number.
  910. % We capitilize Volume because this function is used at the beginning of a
  911. % block.
  912. # endif 0
  913.  
  914. FUNCTION {format.bvolume}
  915. { volume missing$
  916.     { series missing$
  917.     { "" }
  918.     { series italicize }
  919.       if$
  920.     }
  921.     { "Volume~" volume *
  922.       series missing$
  923.     'skip$
  924. #ifndef FRENCH
  925.     { " of " * series italicize * }
  926. #else FRENCH
  927.     { ", s\'{e}rie " * series italicize * }
  928. #endif FRENCH
  929.       if$
  930.     }
  931.   if$
  932. }
  933.  
  934. # if 0
  935. % The format.edition function appends " edition" to the edition, if present.
  936. % We lowercase the edition (it should be something like "Third"), because
  937. % this doesn't start a sentence.
  938. # endif 0
  939.  
  940. FUNCTION {format.edition}
  941. { edition missing$
  942.     { "" }
  943. #ifndef FRENCH
  944.     { edition "ll" change.case$ " edition" * }
  945. #else FRENCH
  946.     { edition "ll" change.case$ " \'{e}dition" * }
  947. #endif FRENCH
  948.   if$
  949. }
  950.  
  951. # if 0
  952. % The format.pages function is used for formatting a page range in a book
  953. % (and in rare circumstances, an article).
  954. % The multi.page.check function examines the page field for a "-" or a ","
  955. % so that format.pages can use "page" instead of "pages" if neither exists.
  956. % Note: global.string.max, set above, here means "take the rest of the string"
  957. %
  958. % VAR: multiresult: INTEGER    (actually, a boolean)
  959. %
  960. % multi.page.check(s) ==
  961. %  BEGIN
  962. %    t := s
  963. %    multiresult := false
  964. %    while ((not multiresult) and (not (t = "")))
  965. %      do
  966. %        if (first character of t = "-" or ",")
  967. %          then multiresult := true
  968. %          else t := t with the first character removed
  969. %        fi
  970. %      od
  971. %    return multiresult
  972. %  END
  973. # endif 0
  974.  
  975. INTEGERS {multiresult}
  976.  
  977. FUNCTION {multi.page.check}
  978. { 't swap$ :=
  979.   'multiresult #0 :=
  980.     { multiresult not
  981.       t "" = not
  982.       and
  983.     }
  984.     { t #1 #1 substring$ "-" =
  985.       t #1 #1 substring$ "," =
  986.       or
  987.     { 'multiresult #1 := }
  988.     { 't t #2 global.string.max substring$ := }
  989.       if$
  990.     }
  991.   while$
  992.   multiresult
  993. }
  994.  
  995. # if 0
  996. % This function doesn't begin a sentence so "pages" isn't capitalized
  997. % other functions that use this should keep that in mind
  998. # endif 0
  999.  
  1000. FUNCTION {format.pages}
  1001. { pages missing$
  1002.     { "" }
  1003.     { pages multi.page.check
  1004.     { "pages~" pages n.dashify * }
  1005.     { "page~" pages n.dashify * }
  1006.       if$
  1007.     }
  1008.   if$
  1009. }
  1010.  
  1011. # if 0
  1012. % The format.vol.num.pages function is for the volume, number, and page range
  1013. % of a journal article.  We use the format:  vol(number):pages, with minor
  1014. % variations for missing fields.  This doesn't begin a sentence.
  1015. # endif 0
  1016.  
  1017. FUNCTION {format.vol.num.pages}
  1018. { volume field.or.null
  1019.   number missing$
  1020.     'skip$
  1021.     { "(" number * ")" * *
  1022.       volume missing$
  1023.     { "Warning: there's a number but no volume in " cite$ * top$ }
  1024.     'skip$
  1025.       if$
  1026.     }
  1027.   if$
  1028.   pages missing$
  1029.     'skip$
  1030.     { duplicate$ "" =
  1031.     'skip$
  1032.     { ":" * }
  1033.       if$
  1034.       pages n.dashify *
  1035.     }
  1036.   if$
  1037. }
  1038.  
  1039. # if 0
  1040. % The format.chapter.pages puts "chapter~" in front of a chapter number,
  1041. % if present, and then appends the pages, if present.
  1042. % This doesn't begin a sentence.
  1043. # endif 0
  1044.  
  1045. FUNCTION {format.chapter.pages}
  1046. { chapter missing$
  1047.     'format.pages
  1048. #ifndef FRENCH
  1049.     { "chapter~" chapter *
  1050. #else FRENCH
  1051.     { "chapitre~" chapter *
  1052. #endif FRENCH
  1053.       pages missing$
  1054.     'skip$
  1055.     { ", " * format.pages * }
  1056.       if$
  1057.     }
  1058.   if$
  1059. }
  1060.  
  1061. # if 0
  1062. % The format.in.ed.booktitle function is used for starting out a sentence
  1063. % that begins "In <booktitle>", putting an editor before the title if one
  1064. % exists.
  1065. # endif 0
  1066.  
  1067. FUNCTION {format.in.ed.booktitle}
  1068. { booktitle missing$
  1069.     { "" }
  1070.     { 's format.editors :=
  1071.       s "" =
  1072. #ifndef FRENCH
  1073.     { "In " booktitle italicize * }
  1074.     { "In " s * ", " * booktitle italicize * }
  1075. #else FRENCH
  1076.     { "Dans " booktitle italicize * }
  1077.     { "Dans " s * ", " * booktitle italicize * }
  1078. #endif FRENCH
  1079.       if$
  1080.     }
  1081.   if$
  1082. }
  1083.  
  1084. # if 0
  1085. % The format.tr.number makes a string starting with "Technical Report"
  1086. % (or type, if that field is defined), followed by the number if there
  1087. % is one (but return the first part even if there is no number)
  1088. # endif 0
  1089.  
  1090. FUNCTION {format.tr.number}
  1091. { type missing$
  1092. #ifndef FRENCH
  1093.     { "Technical Report" }
  1094. #else FRENCH
  1095.     { "Rapport" }
  1096. #endif FRENCH
  1097.     { type }
  1098.   if$
  1099.   number missing$
  1100.     'skip$
  1101. #ifndef FRENCH
  1102.     { "~" * number * }
  1103. #else FRENCH
  1104.     { " no.~" * number * }
  1105. #endif FRENCH
  1106.   if$
  1107. }
  1108.  
  1109. # if 0
  1110. % Now we define the type functions for all entry types that may appear
  1111. % in the .BIB file---e.g., functions like `book' and `article'.  These
  1112. % are the routines that actually generate the .BBL-file output for
  1113. % the entry.  These must all precede the READ command.  In addition, the
  1114. % style designer should have a function `default.type' for unknown types.
  1115. % Note: The fields (within each list) are listed in order of appearance,
  1116. % except as described for a `proceedings'.
  1117. %
  1118. % The article function is for an article in a journal.
  1119. %    Required fields: author, title, journal, year
  1120. %    Optional fields: volume, number, pages, month, note
  1121. %
  1122. % article ==
  1123. %  BEGIN
  1124. %    output.bibitem
  1125. %    output.check("author",format.authors)
  1126. %    new.block
  1127. %    output.check("title",format.title)
  1128. %    new.block
  1129. %    output.check("journal",italicize(field.or.null(journal)))
  1130. %    output(format.vol.num.pages)
  1131. %    output.check("year",format.date)
  1132. %    new.block
  1133. %    output(field.or.null(note))
  1134. %    fin.entry
  1135. %  END
  1136. %
  1137. % The book function is for a whole book.
  1138. %    Required fields: author or editor, title, publisher, year
  1139. %    Optional fields: volume, series, address, edition, month, note
  1140. %
  1141. % book ==
  1142. %  BEGIN
  1143. %    if missing$(author) then output.check("author and editor",
  1144. %                                format.editors)
  1145. %    else output.check("author",format.authors)
  1146. %    fi
  1147. %    new.block
  1148. %    output.check("title",format.btitle)
  1149. %    new.block
  1150. %    output(format.bvolume)
  1151. %    output.check("publisher",field.or.null(publisher))
  1152. %    output(field.or.null(address))
  1153. %    output(format.edition)
  1154. %    output.check("year",format.date))
  1155. %    new.block
  1156. %    output(field.or.null(note))
  1157. %    fin.entry
  1158. %  END
  1159. %
  1160. % The other entry functions are all quite similar, so no "comment version"
  1161. % will be given for them.
  1162. # endif 0
  1163.  
  1164. FUNCTION {article}
  1165. { output.bibitem
  1166.   "author" format.authors output.check
  1167.   new.block
  1168.   "title" format.title output.check
  1169.   new.block
  1170.   "journal" journal field.or.null italicize output.check
  1171.   format.vol.num.pages output
  1172.   "year" format.date output.check
  1173.   new.block
  1174.   note field.or.null output
  1175.   fin.entry
  1176. }
  1177.  
  1178. FUNCTION {book}
  1179. { output.bibitem
  1180.   author missing$
  1181.     { "author and editor" format.editors output.check }
  1182.     { "author" format.authors output.check }
  1183.   if$
  1184.   new.block
  1185.   "title" format.btitle output.check
  1186.   new.block
  1187.   format.bvolume output
  1188.   "publisher" publisher field.or.null output.check
  1189.   address field.or.null output
  1190.   format.edition output
  1191.   "year" format.date output.check
  1192.   new.block
  1193.   note field.or.null output
  1194.   fin.entry
  1195. }
  1196.  
  1197. # if 0
  1198. % A booklet is a bound thing without a publisher or sponsoring institution
  1199. %    Required: title
  1200. %    Optional: author, howpublished, address, month, year, note
  1201. # endif 0
  1202.  
  1203. FUNCTION {booklet}
  1204. { output.bibitem
  1205.   format.authors output
  1206.   new.block
  1207.   "title" format.btitle output.check
  1208.   new.block
  1209.   howpublished field.or.null output
  1210.   address field.or.null output
  1211.   format.date output
  1212.   new.block
  1213.   note field.or.null output
  1214.   fin.entry
  1215. }
  1216.  
  1217. # if 0
  1218. % For the conference entry type, see inproceedings
  1219. # endif 0
  1220.  
  1221. # if 0
  1222. % An inbook is a piece of a book: either a chapter and/or a page range.
  1223. %    Required: author or editor, title, chapter and/or pages, publisher,year
  1224. %    Optional: volume, series, address, edition, month, note
  1225. # endif 0
  1226.  
  1227. FUNCTION {inbook}
  1228. { output.bibitem
  1229.   author missing$
  1230.     { "author and editor" format.editors output.check }
  1231.     { "author" format.authors output.check }
  1232.   if$
  1233.   new.block
  1234.   "title" format.btitle output.check
  1235.   "chapter and pages" format.chapter.pages output.check
  1236.   new.block
  1237.   format.bvolume output
  1238.   "publisher" publisher field.or.null output.check
  1239.   address field.or.null output
  1240.   format.edition output
  1241.   "year" format.date output.check
  1242.   new.block
  1243.   note field.or.null output
  1244.   fin.entry
  1245. }
  1246.  
  1247. # if 0
  1248. % An incollection is like inbook, but where there is a separate title
  1249. % for the referenced thing (and perhaps an editor for the whole)
  1250. %    Required: author, title, booktitle, publisher, year
  1251. %    Optional: editor, chapter, pages, address, month, note
  1252. # endif 0
  1253.  
  1254. FUNCTION {incollection}
  1255. { output.bibitem
  1256.   "authors" format.authors output.check
  1257.   new.block
  1258.   "title" format.title output.check
  1259.   new.block
  1260.   "booktitle" format.in.ed.booktitle output.check
  1261.   format.chapter.pages output
  1262.   "publisher" publisher field.or.null output.check
  1263.   address field.or.null output
  1264.   "year" format.date output.check
  1265.   new.block
  1266.   note field.or.null output
  1267.   fin.entry
  1268. }
  1269.  
  1270. # if 0
  1271. % An inproceedings is an article in a conference proceedings
  1272. %    Required: author, title, booktitle, year
  1273. %    Optional: editor, pages, organization, publisher, address, month, note
  1274. # endif 0
  1275.  
  1276. FUNCTION {inproceedings}
  1277. { output.bibitem
  1278.   "author" format.authors output.check
  1279.   new.block
  1280.   "title" format.title output.check
  1281.   new.block
  1282.   "booktitle" format.in.ed.booktitle output.check
  1283.   format.pages output
  1284.   organization field.or.null output
  1285.   publisher field.or.null output
  1286.   address field.or.null output
  1287.   "year" format.date output.check
  1288.   new.block
  1289.   note field.or.null output
  1290.   fin.entry
  1291. }
  1292.  
  1293. # if 0
  1294. % The conference function is included for Scribe compatibility
  1295. # endif 0
  1296.  
  1297. FUNCTION {conference} { inproceedings }
  1298.  
  1299. # if 0
  1300. % A manual is technical documentation
  1301. %    Required: title
  1302. %    Optional: author, organization, address, edition, month, year, note
  1303. # endif 0
  1304.  
  1305. FUNCTION {manual}
  1306. { output.bibitem
  1307.   format.authors output
  1308.   new.block
  1309.   "title" format.btitle output.check
  1310.   new.block
  1311.   organization field.or.null output
  1312.   address field.or.null output
  1313.   format.edition output
  1314.   format.date output
  1315.   new.block
  1316.   note field.or.null output
  1317.   fin.entry
  1318. }
  1319.  
  1320. # if 0
  1321. % A mastersthesis is a Master's thesis
  1322. %    Required: author, title, school, year
  1323. %    Optional: address, month, note
  1324. # endif 0
  1325.  
  1326. FUNCTION {mastersthesis}
  1327. { output.bibitem
  1328.   "author" format.authors output.check
  1329.   new.block
  1330.   "title" format.btitle output.check
  1331.   new.block
  1332. #ifndef FRENCH
  1333.   "Master's thesis" output
  1334. #else FRENCH
  1335.   "Rapport de ma\^{\i}trise" output
  1336. #endif FRENCH
  1337.   "school" school field.or.null output.check
  1338.   address field.or.null output
  1339.   "year" format.date output.check
  1340.   new.block
  1341.   note field.or.null output
  1342.   fin.entry
  1343. }
  1344.  
  1345. # if 0
  1346. % added for France: rapport de DEA, like master's thesis
  1347. # endif 0
  1348.  
  1349. FUNCTION {deathesis}
  1350. { output.bibitem
  1351.   "author" format.authors output.check
  1352.   new.block
  1353.   "title" format.btitle output.check
  1354.   new.block
  1355. #ifdef FRENCH
  1356.   "Rapport de DEA" output
  1357. #else
  1358.   "Dipl\^{o}me d'Etudes Approfondies Thesis" output
  1359. #endif FRENCH
  1360.   "school" school field.or.null output.check
  1361.   address field.or.null output
  1362.   "year" format.date output.check
  1363.   new.block
  1364.   note field.or.null output
  1365.   fin.entry
  1366. }
  1367.  
  1368. # if 0
  1369. % a misc is something that doesn't fit elsewhere
  1370. %    Required: none
  1371. %    Optional: author, title, howpublished, month, year, note
  1372. # endif 0
  1373.  
  1374. FUNCTION {misc}
  1375. { output.bibitem
  1376.   format.authors output
  1377.   new.block
  1378.   format.title output
  1379.   new.block
  1380.   howpublished field.or.null output
  1381.   format.date output
  1382.   new.block
  1383.   note field.or.null output
  1384.   fin.entry
  1385. }
  1386.  
  1387. # if 0
  1388. % A phdthesis is like a mastersthesis
  1389. %    Required: author, title, school, year
  1390. %    Optional: address, month, note
  1391. # endif 0
  1392.  
  1393. FUNCTION {phdthesis}
  1394. { output.bibitem
  1395.   "author" format.authors output.check
  1396.   new.block
  1397.   "title" format.btitle output.check
  1398.   new.block
  1399. #ifndef FRENCH
  1400.   "PhD thesis" output
  1401. #else FRENCH
  1402.   "Th\`{e}se de Doctorat" output
  1403. #endif FRENCH
  1404.   "school" school field.or.null output.check
  1405.   address field.or.null output
  1406.   "year" format.date output.check
  1407.   new.block
  1408.   note field.or.null output
  1409.   fin.entry
  1410. }
  1411.  
  1412. # if 0
  1413. % a proceedings is a conference proceedings
  1414. % if there is an organization but no editor field, the organization will
  1415. % appear as the first optional field (we try to make the first block nonempty)
  1416. %    Required: title, year
  1417. %    Optional: editor, publisher, organization, address, month, note
  1418. # endif 0
  1419.  
  1420. FUNCTION {proceedings}
  1421. { output.bibitem
  1422.   editor missing$
  1423.     { organization missing$
  1424.     'skip$
  1425.     { organization field.or.null output }
  1426.       if$
  1427.     }
  1428.     { format.editors output }
  1429.   if$
  1430.   new.block
  1431.   "title" format.btitle output.check
  1432.   editor missing$
  1433.     'skip$
  1434.     { organization field.or.null output }
  1435.   if$
  1436.   publisher field.or.null output
  1437.   address field.or.null output
  1438.   "year" format.date output.check
  1439.   new.block
  1440.   note field.or.null output
  1441.   fin.entry
  1442. }
  1443.  
  1444. # if 0
  1445. % a techreport is a technical report.
  1446. %    Required: author, title, institution, year
  1447. %    Optional: type, number, address, month, note
  1448. # endif 0
  1449.  
  1450. FUNCTION {techreport}
  1451. { output.bibitem
  1452.   "author" format.authors output.check
  1453.   new.block
  1454.   "title" format.btitle output.check
  1455.   new.block
  1456.   format.tr.number output
  1457.   "institution" institution field.or.null output.check
  1458.   address field.or.null output
  1459.   "year" format.date output.check
  1460.   new.block
  1461.   note field.or.null output
  1462.   fin.entry
  1463. }
  1464.  
  1465. # if 0
  1466. % an unpublished is something that hasn't been published
  1467. %    Required: author, title, note
  1468. %    Optional: month, year
  1469. # endif 0
  1470.  
  1471. FUNCTION {unpublished}
  1472. { output.bibitem
  1473.   "author" format.authors output.check
  1474.   new.block
  1475.   "title" format.title output.check
  1476.   new.block
  1477.   format.date output
  1478.   new.block
  1479.   "note" note field.or.null output.check
  1480.   fin.entry
  1481. }
  1482.  
  1483. # if 0
  1484. % We use entry type book for an unknown type and give a warning
  1485. # endif 0
  1486.  
  1487. FUNCTION {default.type} { book }
  1488.  
  1489. # if 0
  1490. % Here are macros for common things that may vary from style to style.
  1491. % Users are encouraged to use these macros.
  1492. %
  1493. % Months are either written out in full or abbreviated
  1494. # endif 0
  1495.  
  1496. #if MONTH_FULL
  1497.  
  1498. #ifndef FRENCH
  1499. MACRO {jan} {"January"}
  1500. #else FRENCH
  1501. MACRO {jan} {"janvier"}
  1502. #endif FRENCH
  1503.  
  1504. #ifndef FRENCH
  1505. MACRO {feb} {"February"}
  1506. #else FRENCH
  1507. MACRO {feb} {"f\'{e}vrier"}
  1508. #endif FRENCH
  1509.  
  1510. #ifndef FRENCH
  1511. MACRO {mar} {"March"}
  1512. #else FRENCH
  1513. MACRO {mar} {"mars"}
  1514. #endif FRENCH
  1515.  
  1516. #ifndef FRENCH
  1517. MACRO {apr} {"April"}
  1518. #else FRENCH
  1519. MACRO {apr} {"avril"}
  1520. #endif FRENCH
  1521.  
  1522. #ifndef FRENCH
  1523. MACRO {may} {"May"}
  1524. #else FRENCH
  1525. MACRO {may} {"mai"}
  1526. #endif FRENCH
  1527.  
  1528. #ifndef FRENCH
  1529. MACRO {jun} {"June"}
  1530. #else FRENCH
  1531. MACRO {jun} {"juin"}
  1532. #endif FRENCH
  1533.  
  1534. #ifndef FRENCH
  1535. MACRO {jul} {"July"}
  1536. #else FRENCH
  1537. MACRO {jul} {"juillet"}
  1538. #endif FRENCH
  1539.  
  1540. #ifndef FRENCH
  1541. MACRO {aug} {"August"}
  1542. #else FRENCH
  1543. MACRO {aug} {"ao\^{u}t"}
  1544. #endif FRENCH
  1545.  
  1546. #ifndef FRENCH
  1547. MACRO {sep} {"September"}
  1548. #else FRENCH
  1549. MACRO {sep} {"septembre"}
  1550. #endif FRENCH
  1551.  
  1552. #ifndef FRENCH
  1553. MACRO {oct} {"October"}
  1554. #else FRENCH
  1555. MACRO {oct} {"octobre"}
  1556. #endif FRENCH
  1557.  
  1558. #ifndef FRENCH
  1559. MACRO {nov} {"November"}
  1560. #else FRENCH
  1561. MACRO {nov} {"novembre"}
  1562. #endif FRENCH
  1563.  
  1564. #ifndef FRENCH
  1565. MACRO {dec} {"December"}
  1566. #else FRENCH
  1567. MACRO {dec} {"d\'{e}cembre"}
  1568. #endif FRENCH
  1569.  
  1570. #else !MONTH_FULL
  1571.  
  1572. #ifndef FRENCH
  1573. MACRO {jan} {"Jan."}
  1574. #else FRENCH
  1575. MACRO {jan} {"jan."}
  1576. #endif FRENCH
  1577.  
  1578. #ifndef FRENCH
  1579. MACRO {feb} {"Feb."}
  1580. #else FRENCH
  1581. MACRO {feb} {"f\'{e}v."}
  1582. #endif FRENCH
  1583.  
  1584. #ifndef FRENCH
  1585. MACRO {mar} {"March"}
  1586. #else FRENCH
  1587. MACRO {mar} {"mars"}
  1588. #endif FRENCH
  1589.  
  1590. #ifndef FRENCH
  1591. MACRO {apr} {"Apr."}
  1592. #else FRENCH
  1593. MACRO {apr} {"avr."}
  1594. #endif FRENCH
  1595.  
  1596. #ifndef FRENCH
  1597. MACRO {may} {"May"}
  1598. #else FRENCH
  1599. MACRO {may} {"mai"}
  1600. #endif FRENCH
  1601.  
  1602. #ifndef FRENCH
  1603. MACRO {jun} {"June"}
  1604. #else FRENCH
  1605. MACRO {jun} {"juin"}
  1606. #endif FRENCH
  1607.  
  1608. #ifndef FRENCH
  1609. MACRO {jul} {"July"}
  1610. #else FRENCH
  1611. MACRO {jul} {"juil."}
  1612. #endif FRENCH
  1613.  
  1614. #ifndef FRENCH
  1615. MACRO {aug} {"Aug."}
  1616. #else FRENCH
  1617. MACRO {aug} {"ao\^{u}t"}
  1618. #endif FRENCH
  1619.  
  1620. #ifndef FRENCH
  1621. MACRO {sep} {"Sep."}
  1622. #else FRENCH
  1623. MACRO {sep} {"sep."}
  1624. #endif FRENCH
  1625.  
  1626. #ifndef FRENCH
  1627. MACRO {oct} {"Oct."}
  1628. #else FRENCH
  1629. MACRO {oct} {"oct."}
  1630. #endif FRENCH
  1631.  
  1632. #ifndef FRENCH
  1633. MACRO {nov} {"Nov."}
  1634. #else FRENCH
  1635. MACRO {nov} {"nov."}
  1636. #endif FRENCH
  1637.  
  1638. #ifndef FRENCH
  1639. MACRO {dec} {"Dec."}
  1640. #else FRENCH
  1641. MACRO {dec} {"d\'{e}c."}
  1642. #endif FRENCH
  1643.  
  1644. #endif MONTH_FULL
  1645.  
  1646. # if 0
  1647. % Journals are either written out in full or abbreviated;
  1648. % the abbreviations are like those found in ACM publications.
  1649. %
  1650. % To get a completely different set of abbreviations, it may be best to make
  1651. % a separate .bib file with nothing but those abbreviations; users could then
  1652. % include that file name as the first argument to the \bibliography command
  1653. # endif 0
  1654.  
  1655. #if JOUR_FULL
  1656.  
  1657. MACRO {acmcs} {"ACM Computing Surveys"}
  1658.  
  1659. MACRO {acta} {"Acta Informatica"}
  1660.  
  1661. MACRO {cacm} {"Communications of the ACM"}
  1662.  
  1663. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  1664.  
  1665. MACRO {ibmsj} {"IBM Systems Journal"}
  1666.  
  1667. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  1668.  
  1669. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  1670.  
  1671. MACRO {ieeetcad}
  1672.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  1673.  
  1674. MACRO {ipl} {"Information Processing Letters"}
  1675.  
  1676. MACRO {jacm} {"Journal of the ACM"}
  1677.  
  1678. MACRO {jcss} {"Journal of Computer and System Sciences"}
  1679.  
  1680. MACRO {scp} {"Science of Computer Programming"}
  1681.  
  1682. MACRO {sicomp} {"SIAM Journal on Computing"}
  1683.  
  1684. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  1685.  
  1686. MACRO {tods} {"ACM Transactions on Database Systems"}
  1687.  
  1688. MACRO {tog} {"ACM Transactions on Graphics"}
  1689.  
  1690. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  1691.  
  1692. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  1693.  
  1694. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  1695.  
  1696. MACRO {tcs} {"Theoretical Computer Science"}
  1697.  
  1698. #ifdef FRENCH
  1699. MACRO {tsi} {"Technique et Science Informatiques"}
  1700.  
  1701. #endif FRENCH
  1702. #else !JOUR_FULL
  1703.  
  1704. MACRO {acmcs} {"ACM Comput. Surv."}
  1705.  
  1706. MACRO {acta} {"Acta Inf."}
  1707.  
  1708. MACRO {cacm} {"Commun. ACM"}
  1709.  
  1710. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  1711.  
  1712. MACRO {ibmsj} {"IBM Syst. J."}
  1713.  
  1714. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  1715.  
  1716. MACRO {ieeetc} {"IEEE Trans. Comput."}
  1717.  
  1718. MACRO {ieeetcad}
  1719.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  1720.  
  1721. MACRO {ipl} {"Inf. Process. Lett."}
  1722.  
  1723. MACRO {jacm} {"J. ACM"}
  1724.  
  1725. MACRO {jcss} {"J. Comput. Syst. Sci."}
  1726.  
  1727. MACRO {scp} {"Sci. Comput. Programming"}
  1728.  
  1729. MACRO {sicomp} {"SIAM J. Comput."}
  1730.  
  1731. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  1732.  
  1733. MACRO {tods} {"ACM Trans. Database Syst."}
  1734.  
  1735. MACRO {tog} {"ACM Trans. Gr."}
  1736.  
  1737. MACRO {toms} {"ACM Trans. Math. Softw."}
  1738.  
  1739. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  1740.  
  1741. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  1742.  
  1743. MACRO {tcs} {"Theoretical Comput. Sci."}
  1744.  
  1745. MACRO {tsi} {"Technique et Science Informatiques"}
  1746.  
  1747. #endif JOUR_FULL
  1748.  
  1749. # if 0
  1750. % Now we read in the .BIB entries.
  1751. # endif 0
  1752.  
  1753. READ
  1754.  
  1755. # if 0
  1756. % The sortify function converts to lower case after purify$ing; it's
  1757. % used in sorting and in computing alphabetic labels after sorting
  1758. # endif 0
  1759.  
  1760. #if SORTED
  1761.  
  1762. FUNCTION {sortify}
  1763. { purify$
  1764.   "ll" change.case$
  1765. }
  1766.  
  1767. #endif SORTED
  1768.  
  1769. # if 0
  1770. % This long comment applies only to alphabetic labels
  1771. %
  1772. % The format.lab.names function makes a short label by using the initials of
  1773. % the von and Last parts of the names (but if there are more than four names,
  1774. % (i.e., people) it truncates after three and adds a "*";
  1775. % it also adds a "*" if the last of multiple authors is "others").
  1776. % If there is only one name, and its von and Last parts combined have just
  1777. % a single name-token ("Knuth" has a single token, "Brinch Hansen" has two),
  1778. % we take the first three letters of the last name.
  1779. % In the LONG and ALPHA3 styles, only the name of the first author is
  1780. % considered.
  1781. % In the KEY and SKEY styles, the label is equal to the citation key.
  1782. %
  1783. % format.lab.names(s) ==
  1784. %  BEGIN
  1785. %    numnames := num.names$(s)
  1786. %    if numnames > 1 then
  1787. %        if numnames > 4 then
  1788. %        namesleft := 3
  1789. %        else
  1790. %        namesleft := numnames
  1791. %        nameptr := 1
  1792. %        nameresult := ""
  1793. %        while namesleft > 0
  1794. %          do
  1795. %        if (name_ptr = numnames) and
  1796. %            format.name$(s, nameptr, "{ff}{vv}{ll}{jj}") = "others"
  1797. %            then nameresult := nameresult * "*"
  1798. %            else nameresult := nameresult *
  1799. %                format.name$(s, nameptr, "{v{}}{l{}}")
  1800. %        nameptr := nameptr + 1
  1801. %        namesleft := namesleft - 1
  1802. %          od
  1803. %        if numnames > 4 then
  1804. %        nameresult := nameresult * "*"
  1805. %    else
  1806. %        t := format.name$(s, 1, "{v{}}{l{}}")
  1807. %        if substring$(t, 2, 1) = "" then    % there's just one name-token
  1808. %        nameresult := substring$(purify$(format.name$(s, 1, "{ll}")),
  1809. %                                    1, 3)
  1810. %        else
  1811. %        nameresult := t
  1812. %        fi
  1813. %    fi
  1814. %    nameresult
  1815. %  END
  1816. %
  1817. % Here is a function for calculating the preliminary label of an entry.
  1818. % It is formed by calculating format.lab.names on the author field
  1819. % (or on the editor field if there is no author, or using the first three
  1820. % letters of the key field if there is no editor either), and appending the
  1821. % last two characters (digits) of the year.  It is an error if there is no
  1822. % author, editor or key field, and we use the first three letters of the title
  1823. % in desperation when this happens.  The resulting label is purify$ed, except
  1824. % for possibly a "*" if there are too many authors.
  1825. %
  1826. % This function also calculates the version of this label to be used in sorting
  1827. %
  1828. % The final label may need a trailing 'a', 'b', etc., to distinguish it from
  1829. % otherwise identical labels, but we can't calculated those "extra.label"s
  1830. % until after sorting.
  1831. %
  1832. % calc.label ==
  1833. %  BEGIN
  1834. %    if missing$(author) then
  1835. %        if missing$(editor) then
  1836. %        if missing$(key) then
  1837. %            top$("Warning: need a key to make a label in " * cite$)
  1838. %            label := substring$(purify$(field.or.null(title)), 1, 3)
  1839. %        else
  1840. %            label := substring$(purify$(key), 1, 3)
  1841. %        fi
  1842. %        else
  1843. %        label := format.lab.names(editor)
  1844. %        fi
  1845. %    else
  1846. %        label := format.lab.names(author)
  1847. %    fi
  1848. %    label := label * substring$(purify$(field.or.null(year)), -1, 2)
  1849. %        % assuming we will also sort, we calculate a sort.label
  1850. %    sort.label := sortify(label)
  1851. %  END
  1852. %
  1853. % In the case of the SKEY style, compute the sort.label as above, but do
  1854. %       label := cite$
  1855. % In the case of the KEY style, the above computation is done but not used.
  1856. % It really should be taken out, but what the heck.
  1857. # endif 0
  1858.  
  1859. #if LAB_ALPH
  1860.  
  1861. FUNCTION {format.lab.names}
  1862. { 's swap$ :=
  1863. #if !ALPHA_LONG
  1864.   'numnames s num.names$ :=
  1865.   numnames #1 >
  1866.     { numnames #4 >
  1867.     { 'namesleft #3 := }
  1868.     { 'namesleft numnames := }
  1869.       if$
  1870.       'nameptr #1 :=
  1871.       'nameresult "" :=
  1872.     { namesleft #0 > }
  1873.     { nameptr numnames =
  1874.         { s nameptr "{ff}{vv}{ll}{jj}" format.name$ "others" =
  1875.         { 'nameresult nameresult "*" * := }
  1876.         { 'nameresult nameresult s nameptr "{v{}}{l{}}" format.name$
  1877.           * :=
  1878.         }
  1879.           if$
  1880.         }
  1881.         { 'nameresult nameresult s nameptr "{v{}}{l{}}" format.name$
  1882.           * :=
  1883.         }
  1884.       if$
  1885.       'nameptr nameptr #1 + :=
  1886.       'namesleft namesleft #1 - :=
  1887.     }
  1888.       while$
  1889.       numnames #4 >
  1890.     { 'nameresult nameresult "*" * := }
  1891.     'skip$
  1892.       if$
  1893.     }
  1894.     { 
  1895. #endif ALPHA_LONG
  1896.  
  1897.       't s #1 "{v{}}{l{}}" format.name$ :=
  1898.  
  1899.       'nameresult
  1900.       t #2 #1 substring$ "" =
  1901.  
  1902. #if ALPHA_LONG<2
  1903.     { s #1 "{ll}" format.name$ purify$ #1 #3 substring$ }
  1904. #else ALPHA_LONG
  1905.         { s #1 "{ll}" format.name$ purify$ }
  1906. #endif ALPHA_LONG
  1907.  
  1908.     { t }
  1909.       if$
  1910.       :=
  1911.  
  1912. #if !ALPHA_LONG
  1913.     }
  1914.   if$
  1915. #endif ALPHA_LONG
  1916.  
  1917.   nameresult
  1918. }
  1919.  
  1920. FUNCTION {calc.label}
  1921. { 'label
  1922.   author missing$
  1923.     { editor missing$
  1924.     { key missing$
  1925.         { "Warning: need a key to make a label in " cite$ * top$
  1926.           title field.or.null purify$ #1 #3 substring$
  1927.         }
  1928.         { key purify$ #1 #3 substring$ }
  1929.       if$
  1930.     }
  1931.     { editor format.lab.names }
  1932.       if$
  1933.     }
  1934.     { author format.lab.names }
  1935.   if$
  1936. #if ALPHA_LONG>1
  1937.   " " year field.or.null purify$ #-1 #2 substring$ *
  1938. #else ALPHA_LONG<=1
  1939.   year field.or.null purify$ #-1 #2 substring$
  1940. #endif ALPHA_LONG
  1941.   *
  1942.   :=
  1943. #if SORTED
  1944.   'sort.label label sortify :=
  1945. #endif SORTED
  1946. #if LBKEYS
  1947.   'label cite$ :=
  1948. #endif LBKEYS
  1949. }
  1950.  
  1951. # if 0
  1952. % It doesn't seem like a particularly good idea to use an order-of-citation
  1953. % reference list when using alphabetic labels, but we need to have a
  1954. % special pass to calculate labels when this happens.
  1955. # endif 0
  1956.  
  1957. #if !SORTED
  1958.  
  1959. ITERATE {calc.label}
  1960.  
  1961. #endif !SORTED
  1962.  
  1963. #endif LAB_ALPH
  1964.  
  1965. # if 0
  1966. % When sorting, we compute the sortkey by executing "presort" on each entry.
  1967. % The presort key contains a number of "sortify"ed strings, concatenated
  1968. % with multiple blanks between them.  This makes things like "brinch  per"
  1969. % come before "brinch hansen  per"
  1970. %
  1971. % The fields used here are:
  1972. % the sort.label for alphabetic labels (as set by calc.label),
  1973. % followed by the author names (or editor names, if those are missing,
  1974. % or the key field if both are), followed by the first bit
  1975. % of the title (chopping off a leading "The ", "A ", or "An ").
  1976. % Names are formatted: Von Last First Junior.
  1977. % The names within a part will be separated by a single blank
  1978. % (such as "brinch hansen"), two will separate the name parts themselves
  1979. % (except the von and last), three will separate the names,
  1980. % and four will separate the names from the title (and label, if alphabetic).
  1981. %
  1982. % The sort.format.names function takes an argument that should be in
  1983. % BibTeX name format, and returns a string containing "   "-separated
  1984. % names in the format described above.  The function is almost the same
  1985. % as format.names.
  1986. # endif 0
  1987.  
  1988. #if SORTED
  1989.  
  1990. FUNCTION {sort.format.names}
  1991. { 's swap$ :=
  1992.   'nameptr #1 :=
  1993.   'nameresult "" :=
  1994.   'numnames s num.names$ :=
  1995.   'namesleft numnames :=
  1996.     { namesleft #0 > }
  1997.     { nameptr #1 >
  1998.     { 'nameresult nameresult "   " * := }
  1999.     'skip$
  2000.       if$
  2001. #if NAME_FULL
  2002.       't s nameptr "{vv{ } }{ll{ }}{  ff{ }}{  jj{ }}" format.name$ :=
  2003. #else
  2004.       't s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ :=
  2005. #endif NAME_FULL
  2006.       nameptr numnames = t "others" = and
  2007.     { 'nameresult nameresult "et al" * := }
  2008.     { 'nameresult nameresult t sortify * := }
  2009.       if$
  2010.       'nameptr nameptr #1 + :=
  2011.       'namesleft namesleft #1 - :=
  2012.     }
  2013.   while$
  2014.   nameresult
  2015. }
  2016.  
  2017. # if 0
  2018. % The chop.word(w,len,s) function returns either s or, if the first len
  2019. % letters of s equals w (this comparison is done in the third line of the
  2020. % function's definition), it returns that part of s after w.
  2021. # endif 0
  2022.  
  2023. INTEGERS {len}
  2024.  
  2025. FUNCTION {chop.word}
  2026. { 's swap$ :=
  2027.   'len swap$ :=
  2028.   s #1 len substring$ =
  2029.     { s len #1 + global.string.max substring$ }
  2030.     { s }
  2031.   if$
  2032. }
  2033.  
  2034. # if 0
  2035. % The sort.format.title function returns the argument,
  2036. % but first any leading "A "'s, "An "'s, or "The "'s are removed.
  2037. % The chop.word function uses s, so we need another string variable, t
  2038. # endif 0
  2039.  
  2040. FUNCTION {sort.format.title}
  2041. { 't swap$ :=
  2042.   "A " #2
  2043.     "An " #3
  2044.       "The " #4 t chop.word
  2045.     chop.word
  2046.   chop.word
  2047.   #1 global.string.max substring$
  2048.   sortify
  2049. }
  2050.  
  2051. # if 0
  2052. % There is a limit on the length of an entry string variable, which
  2053. % is what its sort.key$ is.  The limit is currently entry.string.max, so we
  2054. % take at most that many characters of the constructed key, and hope
  2055. % there aren't many references that match to that many characters!
  2056. # endif 0
  2057.  
  2058. FUNCTION {presort}
  2059. {
  2060. #if LAB_ALPH
  2061.   calc.label
  2062.   sort.label
  2063.   "    "
  2064.   *
  2065. #endif LAB_ALPH
  2066.   author missing$
  2067.     { editor missing$
  2068.     { key field.or.null sortify }
  2069.     { editor sort.format.names }
  2070.       if$
  2071.     }
  2072.     { author sort.format.names }
  2073.   if$
  2074. #if LAB_ALPH
  2075.   *
  2076. #endif LAB_ALPH
  2077.   "    "
  2078.   *
  2079.   title field.or.null
  2080.   sort.format.title
  2081.   *
  2082.   #1 entry.string.max substring$
  2083.   'sort.key$ swap$ :=
  2084. }
  2085.  
  2086. ITERATE {presort}
  2087.  
  2088. # if 0
  2089. % And now we can sort
  2090. # endif 0
  2091.  
  2092. SORT
  2093.  
  2094. #endif SORTED
  2095.  
  2096. # if 0
  2097. % This long comment applies only to alphabetic labels, when sorted
  2098. %
  2099. % Now comes the final computation for alphabetic labels, putting in the 'a's
  2100. % and 'b's and so forth if required.  This involves two passes: a forward
  2101. % pass to put in the 'b's, 'c's and so on, and a backwards pass
  2102. % to put in the 'a's (we don't want to put in 'a's unless we know there
  2103. % are 'b's).  However this is not necessary in the 'skeys' style.
  2104. % We have to keep track of the longest (in width$ terms) label, for use
  2105. % by the "thebibliography" environment.
  2106. %
  2107. % VAR: longest.label, last.sort.label, next.extra: string
  2108. %      longest.label.width, last.extra.num: integer
  2109. %
  2110. % initialize.longest.label ==
  2111. %  BEGIN
  2112. %    longest.label := ""
  2113. %    last.sort.label := ""
  2114. %    next.extra := ""
  2115. %    longest.label.width := 0
  2116. %    last.extra.num := 0
  2117. %  END
  2118. %
  2119. % forward.pass ==
  2120. %  BEGIN
  2121. %    if last.sort.label = sort.label then
  2122. %        last.extra.num := last.extra.num + 1
  2123. %        extra.label := int.to.chr$(last.extra.num)
  2124. %    else
  2125. %        last.extra.num := chr.to.int$("a")
  2126. %        extra.label := ""
  2127. %        last.sort.label := sort.label
  2128. %    fi
  2129. %  END
  2130. %
  2131. % reverse.pass ==
  2132. %  BEGIN
  2133. %    if next.extra = "b" then
  2134. %        extra.label := "a"
  2135. %    fi
  2136. %    label := label * extra.label
  2137. %    if width$(label) > longest.label.width then
  2138. %        longest.label := label
  2139. %        longest.label.width := width$(label)
  2140. %    fi
  2141. %    next.extra := extra.label
  2142. %  END
  2143. # endif 0
  2144.  
  2145. #if LAB_ALPH
  2146.  
  2147. #if SORTED
  2148.  
  2149. STRINGS { longest.label last.sort.label next.extra }
  2150.  
  2151. INTEGERS { longest.label.width last.extra.num }
  2152.  
  2153. FUNCTION {initialize.longest.label}
  2154. { 'longest.label "" :=
  2155.   'last.sort.label "" :=
  2156.   'next.extra "" :=
  2157.   'longest.label.width #0 :=
  2158.   'last.extra.num #0 :=
  2159. }
  2160.  
  2161. #   ifndef SKEY
  2162. FUNCTION {forward.pass}
  2163. { last.sort.label sort.label =
  2164.     { 'last.extra.num last.extra.num #1 + :=
  2165.       'extra.label last.extra.num int.to.chr$ :=
  2166.     }
  2167.     { 'last.extra.num "a" chr.to.int$ :=
  2168.       'extra.label "" :=
  2169.       'last.sort.label sort.label :=
  2170.     }
  2171.   if$
  2172. }
  2173. #   endif SKEY
  2174.  
  2175. FUNCTION {reverse.pass}
  2176. #  ifndef SKEY
  2177.   next.extra "b" =
  2178.     { 'extra.label "a" := }
  2179.     'skip$
  2180.   if$
  2181.   'label label extra.label * :=
  2182. #  endif SKEY
  2183.   label width$ longest.label.width >
  2184.     { 'longest.label label :=
  2185.       'longest.label.width label width$ :=
  2186.     }
  2187.     'skip$
  2188.   if$
  2189.   'next.extra extra.label :=
  2190. }
  2191.  
  2192. EXECUTE {initialize.longest.label}
  2193.  
  2194. #   ifndef SKEY
  2195. ITERATE {forward.pass}
  2196. #   endif SKEY
  2197.  
  2198. REVERSE {reverse.pass}
  2199.  
  2200.  
  2201. #else !SORTED
  2202.  
  2203. # if 0
  2204. % It still doesn't seem like a good idea to use an order-of-citation
  2205. % reference list when using alphabetic labels, but when this happens we
  2206. % must compute the longest label
  2207. # endif 0
  2208.  
  2209. STRINGS {longest.label}
  2210.  
  2211. INTEGERS {longest.label.width}
  2212.  
  2213. FUNCTION {initialize.longest.label}
  2214. { 'longest.label "" :=
  2215.   'longest.label.width #0 :=
  2216. }
  2217.  
  2218. FUNCTION {longest.label.pass}
  2219. { label width$ longest.label.width >
  2220.     { 'longest.label label :=
  2221.       'longest.label.width label width$ :=
  2222.     }
  2223.     'skip$
  2224.   if$
  2225. }
  2226.  
  2227. EXECUTE {initialize.longest.label}
  2228.  
  2229. ITERATE {longest.label.pass}
  2230.  
  2231. #endif SORTED
  2232.  
  2233. #else !LAB_ALPH
  2234.  
  2235. # if 0
  2236. % Now comes the computation for numeric labels.
  2237. % We use either the sorted order or original order.
  2238. % We still have to keep track of the longest (in width$ terms) label, for use
  2239. % by the "thebibliography" environment.
  2240. # endif 0
  2241.  
  2242. STRINGS {longest.label}
  2243.  
  2244. INTEGERS { number.label longest.label.width }
  2245.  
  2246. FUNCTION {initialize.longest.label}
  2247. { 'longest.label "" :=
  2248.   'number.label #1  :=
  2249.   'longest.label.width #0 :=
  2250. }
  2251.  
  2252. FUNCTION {longest.label.pass}
  2253. { 'label number.label int.to.str$ :=
  2254.   'number.label number.label #1 + :=
  2255.   label width$ longest.label.width >
  2256.     { 'longest.label label :=
  2257.       'longest.label.width label width$ :=
  2258.     }
  2259.     'skip$
  2260.   if$
  2261. }
  2262.  
  2263. EXECUTE {initialize.longest.label}
  2264.  
  2265. ITERATE {longest.label.pass}
  2266.  
  2267. #endif LAB_ALPH
  2268.  
  2269. # if 0
  2270. % Now we're ready to start writing the .BBL file.
  2271. % First we write the `preamble' containing the command
  2272. %     \begin{thebibliography}{...}
  2273. % where the `...' is the longest label.
  2274. %
  2275. % Then we call init.state.consts, for use by the output routines.
  2276. # endif 0
  2277.  
  2278. FUNCTION {preamble}
  2279. { "\begin{thebibliography}{"  longest.label  * "}" * write$
  2280.   newline$
  2281. }
  2282.  
  2283. EXECUTE {preamble}
  2284.  
  2285. EXECUTE {init.state.consts}
  2286.  
  2287. # if 0
  2288. % Now we produce the output for all the entries
  2289. # endif 0
  2290.  
  2291. ITERATE {call.type$}
  2292.  
  2293. # if 0
  2294. % Finally, we finish up by writing the `\end{thebibliography}' command.
  2295. # endif 0
  2296.  
  2297. FUNCTION {finish.up} { newline$ "\end{thebibliography}" write$ newline$ }
  2298.  
  2299. EXECUTE {finish.up}
  2300.